]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
windowManager: Add switch-to-application-n keybindings
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 29 Jan 2019 10:48:06 +0000 (11:48 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Tue, 5 Feb 2019 11:33:30 +0000 (11:33 +0000)
Having Unity-like shortcuts for activating the first nine applications
in the dash has been a long requested feature, but somehow nobody got
around to implement it.

As the shortcut is most useful outside the overview where the dash is
not visible, only consider favorite apps as they have a predictable
order.

https://bugzilla.gnome.org/show_bug.cgi?id=648000

data/org.gnome.shell.gschema.xml.in
js/ui/windowManager.js

index 87898a36e7f330e463d7868409179eedc95992e0..24e2a75b018fa1226310c4e769b2f3f8684d7c69 100644 (file)
       <summary>Keybinding that pauses and resumes all running tweens, for debugging purposes</summary>
       <description></description>
     </key>
+    <key name="switch-to-application-1" type="as">
+      <default>["&lt;Super&gt;1"]</default>
+      <summary>Switch to application 1</summary>
+    </key>
+    <key name="switch-to-application-2" type="as">
+      <default>["&lt;Super&gt;2"]</default>
+      <summary>Switch to application 2</summary>
+    </key>
+    <key name="switch-to-application-3" type="as">
+      <default>["&lt;Super&gt;3"]</default>
+      <summary>Switch to application 3</summary>
+    </key>
+    <key name="switch-to-application-4" type="as">
+      <default>["&lt;Super&gt;4"]</default>
+      <summary>Switch to application 4</summary>
+    </key>
+    <key name="switch-to-application-5" type="as">
+      <default>["&lt;Super&gt;5"]</default>
+      <summary>Switch to application 5</summary>
+    </key>
+    <key name="switch-to-application-6" type="as">
+      <default>["&lt;Super&gt;6"]</default>
+      <summary>Switch to application 6</summary>
+    </key>
+    <key name="switch-to-application-7" type="as">
+      <default>["&lt;Super&gt;7"]</default>
+      <summary>Switch to application 7</summary>
+    </key>
+    <key name="switch-to-application-8" type="as">
+      <default>["&lt;Super&gt;8"]</default>
+      <summary>Switch to application 8</summary>
+    </key>
+    <key name="switch-to-application-9" type="as">
+      <default>["&lt;Super&gt;9"]</default>
+      <summary>Switch to application 9</summary>
+    </key>
   </schema>
 
   <schema id="org.gnome.shell.keyboard" path="/org/gnome/shell/keyboard/"
index 2cb8dfb318a6f0bcefa9c0b3e801aef6cfe59a45..8450cfd333bd3a72789ee1e5aaaee9fbb58b6707 100644 (file)
@@ -12,6 +12,7 @@ const Shell = imports.gi.Shell;
 const Signals = imports.signals;
 
 const AltTab = imports.ui.altTab;
+const AppFavorites = imports.ui.appFavorites;
 const Dialog = imports.ui.dialog;
 const WorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup;
 const InhibitShortcutsDialog = imports.ui.inhibitShortcutsDialog;
@@ -938,6 +939,69 @@ var WindowManager = class {
                            Shell.ActionMode.POPUP,
                            this._toggleCalendar.bind(this));
 
+        this.addKeybinding('switch-to-application-1',
+                           new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
+                           Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+                           Shell.ActionMode.NORMAL |
+                           Shell.ActionMode.OVERVIEW,
+                           this._switchToApplication.bind(this));
+
+        this.addKeybinding('switch-to-application-2',
+                           new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
+                           Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+                           Shell.ActionMode.NORMAL |
+                           Shell.ActionMode.OVERVIEW,
+                           this._switchToApplication.bind(this));
+
+        this.addKeybinding('switch-to-application-3',
+                           new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
+                           Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+                           Shell.ActionMode.NORMAL |
+                           Shell.ActionMode.OVERVIEW,
+                           this._switchToApplication.bind(this));
+
+        this.addKeybinding('switch-to-application-4',
+                           new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
+                           Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+                           Shell.ActionMode.NORMAL |
+                           Shell.ActionMode.OVERVIEW,
+                           this._switchToApplication.bind(this));
+
+        this.addKeybinding('switch-to-application-5',
+                           new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
+                           Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+                           Shell.ActionMode.NORMAL |
+                           Shell.ActionMode.OVERVIEW,
+                           this._switchToApplication.bind(this));
+
+        this.addKeybinding('switch-to-application-6',
+                           new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
+                           Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+                           Shell.ActionMode.NORMAL |
+                           Shell.ActionMode.OVERVIEW,
+                           this._switchToApplication.bind(this));
+
+        this.addKeybinding('switch-to-application-7',
+                           new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
+                           Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+                           Shell.ActionMode.NORMAL |
+                           Shell.ActionMode.OVERVIEW,
+                           this._switchToApplication.bind(this));
+
+        this.addKeybinding('switch-to-application-8',
+                           new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
+                           Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+                           Shell.ActionMode.NORMAL |
+                           Shell.ActionMode.OVERVIEW,
+                           this._switchToApplication.bind(this));
+
+        this.addKeybinding('switch-to-application-9',
+                           new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
+                           Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+                           Shell.ActionMode.NORMAL |
+                           Shell.ActionMode.OVERVIEW,
+                           this._switchToApplication.bind(this));
+
         global.display.connect('show-resize-popup', this._showResizePopup.bind(this));
         global.display.connect('show-pad-osd', this._showPadOsd.bind(this));
         global.display.connect('show-osd', (display, monitorIndex, iconName, label) => {
@@ -2012,6 +2076,14 @@ var WindowManager = class {
         Main.ctrlAltTabManager.popup(binding.is_reversed(), binding.get_name(), binding.get_mask());
     }
 
+    _switchToApplication(display, window, binding) {
+        let [,,,target] = binding.get_name().split('-');
+        let apps = AppFavorites.getAppFavorites().getFavorites();
+        let app = apps[target - 1];
+        if (app)
+            app.activate();
+    }
+
     _toggleAppMenu(display, window, event, binding) {
         Main.panel.toggleAppMenu();
     }